package org.example;

import org.example.biz.HelloBiz;
import org.example.dao.UsbDisk;
import org.springframework.context.annotation.*;

import java.util.Date;

// Spring 配置类
@Configuration
// 扫描该包及其所有的子包
@ComponentScan("org.example")
// 开启Aspect自动代理
@EnableAspectJAutoProxy
public class IocConfig {

    @Bean("hello")
    @DependsOn("myname")
    @Primary
    public HelloBiz helloBiz(){
        return new HelloBiz("张三");
    }

    @Bean("hello1")
    @Scope("prototype")
    public HelloBiz helloBiz1(){
        return new HelloBiz("李四");
    }

    @Bean
    @Lazy
    public Date today(){
        System.out.println("---------------today");
        return new Date();
    }

    @Bean("myname")
    public String myName(){
        System.out.println("---------------myName");
        return "yc";
    }

    public Object noBean(){
        return new Object();
    }

    @Bean
    public UsbDisk uDisk(){
        UsbDisk usbDisk = new UsbDisk();
        usbDisk.sn = "00002";
        return usbDisk;
    }

}
